/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ejb.dao;

import ejb.entities.Invitation;
import ejb.entities.User;
import ejb.entities.Event;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ejb.Stateless;

@Stateless
public class InvitationDAO extends GenericDAO<Invitation> {
    public InvitationDAO() {
		super(Invitation.class);
	}
    
        public List<Invitation> findInvitationByUser(User user) {
		Map<String, Object> parameters = new HashMap<>();
		parameters.put("user", user);
		String query = "select u from Invitation u where u.inviteduser = :user";
		return super.findManyResult(query, parameters);
	}
        
	public List<Invitation> findInvitationByEvent(Event evented) {
		Map<String, Object> parameters = new HashMap<>();
		parameters.put("event", evented);
		String query = "select u from Invitation u where u.event = :event";
		return super.findManyResult(query, parameters);
	}
        
}